package com.example.demo.util;


import org.springframework.util.StopWatch;

import java.util.concurrent.CountDownLatch;

public class Task {
    public static void main(String[] args) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        java.util.concurrent.CountDownLatch countDownLatch = null;
        try {
            countDownLatch = new CountDownLatch(10);
            for (int i = 0; i < 10; i++) {
                try {
                    Thread.sleep(100);
                    stopWatch.stop();
                    boolean running = stopWatch.isRunning();
                    System.out.println(running);
                    stopWatch.start();
                    //RamUsageEstimator.humanReadableUnits(RamUsageEstimator.sizeOf());
                    //System.out.println(s);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                countDownLatch.countDown();
                long count = countDownLatch.getCount();
                System.out.println(count);
            }

        } finally {
            try {
                assert countDownLatch != null;
                countDownLatch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("await" + stopWatch.prettyPrint());
        }

    }
}
